package popcorn.ticket.serviceimpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import popcorn.ticket.dao.MovieTypesMapper;
import popcorn.ticket.entity.MovieTypes;
import popcorn.ticket.entity.MovieTypesExample;
import popcorn.ticket.service.MovieTypeService;
import popcorn.ticket.tool.PageData;
@Service
@Transactional(propagation=Propagation.REQUIRED,isolation = Isolation.READ_COMMITTED)
public class MovieTypeServiceImpl implements MovieTypeService{
	
	@Autowired
	MovieTypesMapper mtm;
	
	@Override
	public long countByExample(MovieTypesExample example) {
		
		return mtm.countByExample(example);
	}
	@Override
	public int deleteByPrimaryKey(Integer mtypeid) {
		
		return mtm.deleteByPrimaryKey(mtypeid);
	}
	@Override
	public int deleteByExample(MovieTypesExample example) {
		// TODO Auto-generated method stub
		return mtm.deleteByExample(example);
	}
	@Override
	public int insert(MovieTypes record) {
		// TODO Auto-generated method stub
		return mtm.insert(record);
	}
	@Override
	public PageData<MovieTypes> selectByExample(MovieTypesExample example,int page,int pageSize) {
		PageHelper.startPage(page, pageSize);
		List<MovieTypes> list = mtm.selectByExample(example);
		PageInfo<MovieTypes> pi = new PageInfo<MovieTypes>(list);
		PageData<MovieTypes> pd = new PageData<MovieTypes>(list, page, (int)pi.getTotal(), pageSize);
		return pd;
	}
	@Override
	public MovieTypes selectByPrimaryKey(Integer mtypeid) {
		
		return mtm.selectByPrimaryKey(mtypeid);
	}
	@Override
	public int updateByPrimaryKeySelective(MovieTypes record) {
		// TODO Auto-generated method stub
		return mtm.updateByPrimaryKeySelective(record);
	}
	
	@Override
	public List<MovieTypes> selectAllType() {
		MovieTypesExample example = new MovieTypesExample();
		example.createCriteria().andMtypeidIsNotNull();
		return mtm.selectByExample(example);
	}
	
}
